import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import './index.less';
import * as T from './types';
import actions from './actions';
import { store2Props } from './selectors';
import SegmentTab from './components/segment-tab';
import StatusTab from './components/status-tab';
import GiftStatusTab from './components/gift-status-tab';
import CouponBox from './components/couponBox';
import GiftBox from './components/giftBox';
import PropBox from './components/propBox';
//@ts-ignore
actions().actions.loadReducer();
//@ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class PackageACustomerMyCoupon extends Component<Partial<T.IProps>, any> {
  componentDidShow() {
    this.props.actions.init();
  }

  componentWillMount() {
    if (__TARO_ENV !== 'h5') {
      Taro.showShareMenu({
        withShareTicket: true,
      });
    }
  }
  onShareAppMessage() {
    let wechatShareInfo = JSON.parse(Taro.getStorageSync('wechatShareInfo'));
    return {
      title: wechatShareInfo.title,
      imageUrl: wechatShareInfo.imgUrl[0].url,
    };
  }
  onShareTimeline() {
    // 默认分享内容
  }

  componentWillUnmount() {
    this.props.actions.clean();
  }
  render() {
    let {
      // actions: {action},
      main: { segmentTab },
      main,
    } = this.props;
    return (
      main && (
        <View className="packageIBackpack">
          {/* <SegmentTab /> */}
          {segmentTab != 1 && <StatusTab /> }
          {/* {segmentTab == 1 && <GiftStatusTab />} */}
          {/* 卡券 */}
          {/* {segmentTab == 0 && <CouponBox/>} */}
          {/* 礼包 */}
          {/* {segmentTab == 1 && <GiftBox /> } */}
          {/* 道具 */}
          {segmentTab == 2 && <PropBox /> }
        </View>
      )
    );
  }
}

//create by moon https://github.com/creasy2010/moon
